﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DAO;

namespace Sklad.WindowsApplication
{
    public partial class AddProviderForm : Form
    {
        public AddProviderForm()
        {
            InitializeComponent();
            this.cb_type.Items.AddRange(AdminMainForm.dr.KindRepository.GetAll().ToArray());
        }

        private void bt_add_Click(object sender, EventArgs e)
        {
            var tempSel = cb_type.SelectedItem as Kind;
            var temp = new Provider()
            {
                Name = this.tb_name.Text,
                Address = this.tb_address.Text,
                Phone__Number = this.tb_phone_number.Text,
                Id_Kind = tempSel.Id
            };

            AdminMainForm.dr.ProviderRepository.Add(temp);
            this.Close();
        }

        private void bt_cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
